﻿using Framework;
using System.Collections.Generic;
using UnityEngine;
public class WeaponDataSingle : ISingeleton
{
    public static WeaponDataSingle Intacne => Singleton<WeaponDataSingle>.Instance;

    private Dictionary<WeaponEnum, WeaponInfo> dic = new Dictionary<WeaponEnum, WeaponInfo>();
    private Dictionary<WeaponEnum, bool> BuyDic = new Dictionary<WeaponEnum, bool>();
    public void Init()
    {
        foreach (var item in Resources.Load<WeaponSO>("SO/WeaponSO"))
        {
            if(dic.ContainsKey(item.WeaponType))
            {
                Debug.Log(item.WeaponType.ToString() + "重复添加");
            }
            else
            {
                dic.Add(item.WeaponType, item);
                BuyDic.Add(item.WeaponType, false);
            }
        }
    }
    //获取武器数据
    public WeaponInfo GetWeapomInfo(WeaponEnum type) => dic[type];

    //获取武器是否购买
    public bool GetIsBuyWeapom(WeaponEnum type) => BuyDic[type];
    //购买武器,返回是否成功
    public bool BuyWeapom(WeaponEnum type)
    {
        if (GetIsBuyWeapom(type))
        {
            return false;
        }
        BuyDic[type] = true;
        return BuyDic[type];
    }
}
